![]() |
SNAP - 07 (Introduction to Variables Part 2) OPENING QUESTIONS: Can you suggest an instance when it might not be wise to have a variable that is available to ALL parts of your program? OBJECTIVES:
WORD FOR TODAY:
TIPS O' THE DAY: 1) ALWAYS have a 'clear' button ( 2) You can also 'delete' a script by dragging it off the scripting area 3) If you know the name of a block but can't remember where it is, use the ALWAYS helpful ctrl-F key (that works on web sites AND pdf documents by the way) 4) How can you *duplicate* a script or part of a script (this will be VERY helpful in today's lab) 5) Always a good idea to have an x 'go to 0' and a y 'go to 0' to re-center your sprite if it get's lost 6) Right Mouse click on the stage and select 'show all' to bring sprite(s) back WORK O' THE DAY: Very quickly -- please write down a list of our "BEST PRACTICES" Compare your list to your group... do they match? Any questions, comments or concerns about our list so far? (Some of which we haven't put into practice, oddly enough) ═══════════════════════════ Open snap and create a new script
═══════════════════════════ Now please return to your first sprite and:
Notice that the system variable Now please create a variable called "NAME" and change your code in the first script so that the user input is stored in the "NAME" variable. Notice that the NAME variable is ALSO available to sprites 2 and 3... (How can you tell?) ═══════════════════════════ The answer system variable is available to all parts of all scripts of your program at all times. That can be really helpful at times.... Please have a conversation with your group to outline why it can be VERY helpful to have information available GLOBALLY... in other words, every program in every sprite can see, access and change the data in a global variable. ═══════════════════════════ Now please go to your second variable and take a look at the code there. This time, I'm going to have you create a similar script that asks the user for their age and save that information to a SCRIPT VARIABLE named "Local Name". Open your 3rd sprite and notice that the "Local Name" script variable that you created in your 2nd sprite is not avaialble... why might that be an advantage? ═══════════════════════════
|